package com.xju.edu;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;


@Component
public class Demo {
    @Value("${uname}")
    private String name;
    @Value("${uage}")
    private int age;
    @Value("#{@list1}")
    private List<String> list;
    @Value("#{@set1}")
    private Set<String> set;
    @Value("#{@map1}")
    private Map<String,Object> map;
    @Value("#{@properties1}")
    private Properties properties;
    /*设置引用类型：DI注入*/
    // @Autowired 实现自动装配的注解，可以完成自定义bean类型属性的注入
    // 说明：先按照类型进行匹配，如果找到唯一的就注入
    // 如果找不到，就按照id进行注入，如果都找不到，抛出异常

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public Set<String> getSet() {
        return set;
    }

    public void setSet(Set<String> set) {
        this.set = set;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    @Override
    public String toString() {
        return "Demo{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", list=" + list +
                ", set=" + set +
                ", map=" + map +
                ", properties=" + properties +
                '}';
    }
}
